﻿using System.Web.Mvc;
using PB.Web.Infrastructure;
using RHD.Common.Web.Utility.Extensions;

namespace RHD.Web.Infrastructure {
	public abstract class ViewPageBase : WebViewPage, IViewPageBase {
		public Principal Principal {
			get { return ((BaseController)this.ViewContext.Controller).Principal; }
		}

		#region IViewPageBase Members

		public string Title {
			get { return ViewData.GetValue<string>(ViewDataKeys.TITLE); }
			set { ViewData.SetValue<string>(ViewDataKeys.TITLE, value); }
		}

		public string Subtitle {
			get { return ViewData.GetValue<string>(ViewDataKeys.SUBTITLE); }
			set { ViewData.SetValue<string>(ViewDataKeys.SUBTITLE, value); }
		}

		public NavBarType Bar {
			get { return ViewData.GetValue<NavBarType>(ViewDataKeys.BAR); }
			set { ViewData.SetValue<NavBarType>(ViewDataKeys.BAR, value); }
		}

		#endregion
	}

	public abstract class ViewPageBase<T> : WebViewPage<T>, IViewPageBase {
		public Principal Principal {
			get { return ((BaseController)this.ViewContext.Controller).Principal; }
		}

		public override void Execute() {
		}

		#region IViewPageBase Members

		public string Title {
			get { return ViewData.GetValue<string>(ViewDataKeys.TITLE); }
			set { ViewData.SetValue<string>(ViewDataKeys.TITLE, value); }
		}

		public string Subtitle {
			get { return ViewData.GetValue<string>(ViewDataKeys.SUBTITLE); }
			set { ViewData.SetValue<string>(ViewDataKeys.SUBTITLE, value); }
		}

		public NavBarType Bar {
			get { return ViewData.GetValue<NavBarType>(ViewDataKeys.BAR); }
			set { ViewData.SetValue<NavBarType>(ViewDataKeys.BAR, value); }
		}

		#endregion
	}

	public interface IViewPageBase {
		string Title { get; set; }
		string Subtitle { get; set; }
		NavBarType Bar { get; set; }
	}
}